package com.zkdcloud.controller;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.SQLExec;
import org.junit.Test;

import java.io.File;

/**
 * ant Sql Test
 * @author zk123
 * @version 2018/4/15
 */
public class AntExec {

    @Test
    public void testAntSql(){
        SQLExec sqlExec = new SQLExec();
        sqlExec.setPassword("");
        sqlExec.setUrl("jdbc:h2:~/loms");
        sqlExec.setUserid("sa");
        sqlExec.setDriver("org.h2.Driver");

        String filePath = Thread.currentThread().getContextClassLoader().getResource("init.sql").getPath();
        sqlExec.setSrc(new File(filePath));
        sqlExec.setPrint(true);
        sqlExec.setProject(new Project());
        sqlExec.execute();
    }
}
